#include "Teacher.h"
#include<iostream>
void Teacher::AddToClass(IStudent* Student)
{
	if (FindStudent(Student)) {
		std::cout << "Can't add the student " << Student->GetID() << " as the student already in the teacher " << this->TeacherID << std::endl;
		return;
	}
	else {
		Students.push_back(Student);
		std::cout << "Add the student " << Student->GetID() << " into the teacher " << this->TeacherID << std::endl;
	}
}

void Teacher::DeleteFromClass(IStudent* Student)
{
	if (!FindStudent(Student)){
		std::cout << "Can't delete the student " << Student->GetID() << " as the student isn't in the teacher " << this->TeacherID << std::endl;
		return;
	}
	else{
		Students.remove(Student);
		std::cout << "Delete the student " << Student->GetID() << " From the teacher " << this->TeacherID << std::endl;
	}
}

void Teacher::SetInfomation(std::string SetInfomation)
{
	Message Info(TeacherID, SetInfomation);
	Infomation= Info;
}

void Teacher::Info() const
{
	std::cout << "The teacher " << this->TeacherID << " published :" << this->Infomation.GetMessage() << std::endl;
	int numb=0;
	for(const auto &Student : Students){
		if (Student->Update(this->Infomation)) {
			numb++;
		}
	}
	std::cout << "There are " << numb << " student recived message:" << std::endl << std::endl;
}

int Teacher::GetID() const
{
	return TeacherID;
}

bool Teacher::FindStudent(IStudent* Student) const
{
	for(const auto & IStudent : Students){
		if (IStudent == Student)
			return true;
	}
	return false;
}


